<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>去除数组连续项元素</title>
  </head>
  <body>
    <script>
      let arr = ["a", "a", "a", "c", "b", "c", "c"];
      function removeSerial(arr) {
        let newArr = [];
        for (let i = 0; i < arr.length; i++) {
          if (arr[i] === arr[i + 1]) {
            arr.splice(arr[i], arr[i + 1]);
          } else {
            newArr.push(arr[i]);
          }
        }
        return newArr;
      }
      console.log(removeSerial(arr));
    </script>
  </body>
</html>
